

# 209。长度最小的子数组

def shortArray(n,target):
    min = 99999
    for i in range(0,len(n)):
        if n[i] >= target:
            min = 1
        elif n[i]<target:
            temp = n[i]
            for j in range(i+1,len(n)):
                temp = temp + n[j]
                if temp >= target:
                    if (j - i + 1) < min:
                        min = j - i + 1
                if temp>target:
                    break
    if min == 99999:
        return -1
    else:
        return min

if __name__ == "__main__":
    arr = input()
    n = [int(i) for i in arr.split()]
    target = int(input())
    result = shortArray(n,target)
    print(result)